//---------------------------------------------------------------------------

#ifndef TMessageManagerH
#define TMessageManagerH
//---------------------------------------------------------------------------
#include "common.h"
namespace WYHGloox{
	typedef std::list<MessageSession*> TSessionBox;
	class TMessageManager : public MessageSessionHandler,MessageEventHandler, MessageHandler, ChatStateHandler
	{
	   private:
			Client *_client;
			MessageSession *_session;
			MessageEventFilter *_messageEventFilter;
			ChatStateFilter *_chatStateFilter;
	   public:
			TMessageManager(Client *client);
			TSessionBox SessionBox;
			bool __fastcall Find(MessageSession *session,unsigned int *index,TSessionBox::iterator it);
			MessageSession * __fastcall Find(unsigned int index,TSessionBox::iterator it);
			bool __fastcall Put(MessageSession *session);
			virtual ~TMessageManager();
			virtual void handleMessage( const Message& msg, MessageSession * session );
			virtual void handleMessageEvent( const JID& from, MessageEventType event );
			virtual void handleChatState( const JID& from, ChatStateType state );
			virtual void handleMessageSession( MessageSession *session );
			TOnMessageSession FOnMessageSession;
			TOnMessage  FOnMessage;
			TOnMessageEvent FOnMessageEvent;
			TOnChatState FOnChatState;
	};

};
using namespace WYHGloox;
#endif
